package org.stvd.service.base.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.stvd.repository.base.BaseDao;
import org.stvd.service.base.BaseService;

@Service("BaseService")
public class BaseServiceImpl<T> implements BaseService<T> {

    @Resource(name = "BaseDao")
    @Lazy
    private BaseDao<T> baseDao;

    @Override
    public T findByPk(Class<T> t, Object pk) {
        return baseDao.findByPk(t, pk);
    }
    
    @Override
    public List<T> findAll(Class<T> t) {
        return baseDao.findAll(t);
    }

    @Override
    @Transactional
    public void insert(T entity) {
        baseDao.insert(entity);
    }

    @Override
    @Transactional
    public void update(T entity) {
        baseDao.update(entity);
    }
    
    @Override
    @Transactional
    public void delete(Class<T> t, Object pk) {
        baseDao.delete(t, pk);
    }
}
